package de.jonasblatt.networkapi.rpi.network.server;

import de.jonasblatt.networkapi.rpi.model.NetworkModel;
import de.jonasblatt.networkapi.rpi.network.commands.ClientCommand;
import de.jonasblatt.networkapi.rpi.network.commands.Command;

public interface Server extends Runnable {

	/**
	 * Closes the socket and tells the executing thread to stop as well.
	 */
	public void closeConnection();

	/**
	 * Returns the host's associated id
	 *
	 * @return
	 */
	public int getHostID();

	public NetworkModel getModel();

	/**
	 * Server is notified, that a new ClientCommand arrived. The ClientCommand
	 * is added to the Command queue of the Schedule.
	 *
	 * @param cmd
	 */
	public void notify(ClientCommand cmd);

	/**
	 * Removes a ServiceWorker from the server's observer list
	 *
	 * @param observer
	 */
	public void remove(ServerWorker observer);

	/**
	 * Sets the host's associated id
	 *
	 * @param hostID
	 */
	public void setHostID(int hostID);

	public void setModel(NetworkModel model);

	/**
	 * Sends a Command to all Clients
	 *
	 * @param msg
	 */
	public void updateAll(Command msg);

	public boolean updateClient(int clientID, Command msg);
}